package com.example.controller;

import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: zt
 * @Date: 2021/4/29 17:00
 * @Description:
 */
@RestController//相当于 @Controller + @ResponseBody 返回 json，因此 无法返回 jsp。thymeleaf 也不能用该注解
@RequestMapping("/test")
public class TestController {

    // 注意一定要 GET 方式，POST方式是 Spring Security 默认的校验接口
    @GetMapping(value = {"/hello"})
    public String hello() {
        return "hello Security";
    }

    @GetMapping(value = {"/home"})
    public String home() {
        return "这里是首页";
    }

    @GetMapping(value = {"/auth"})
    public String authTest() {
        return "authTest";
    }

    @GetMapping("update")
    @Secured({"ROLE_sale"})
    public String update() {
        return "you can update.";
    }
}
